package com.sghd.fight.module.game.service.skill.effect;

import com.sghd.fight.module.game.config.SkillConfig;
import com.sghd.fight.module.game.core.model.Unit;
import com.sghd.fight.module.game.service.room.IRoom;
import com.sghd.fight.module.game.service.skill.Context;
import com.sghd.pojo.fight.game.*;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author frank
 * @date 2018-12-07 14:18
 * @desc 绑带治疗
 **/
@Component
public class BandageEffect implements Effect {

    @Override
    public void execute(Context context, IRoom room, Unit owner, Unit target, Map<String, Object> ctx, SkillReport skillReport, TargetReport targetReport, SkillConfig config) {
        ChessType type = ChessType.valueOf(ctx.get(Effect.TARGET).toString());
        int magic = target.getMagic(type);
        target.getMagic().update(type, -magic);//
        magic += getAddedHp(owner, room, config.getType());

        context.addValue(target, UnitValue.HP, magic);
        targetReport.addValue(ValueItem.valueOf(UnitValue.HP, magic));
    }

    @Override
    public EffectType getType() {
        return EffectType.SK_BANDAGE;
    }
}
